<!--
 * @Description: 
 * @Author: mmzhang
 * @Date: 2022-11-21 10:23:17
 * @LastEditTime: 2022-12-21 15:58:57
-->
<template>
  <div class="allCustomersManagement">
    <div class="export">
      <Button type="primary" @click="backListReportExport">导出excel</Button>
      <Button type="primary" class="aciton" style="margin-right:10px;"> <a
          href="https://images.tospurfang.com/doc/%E7%BD%AE%E4%B8%9A%E8%AE%A1%E5%88%92%E4%B9%A6%E6%93%8D%E4%BD%9C%E8%AF%B4%E6%98%8E.pdf"
          style="color:#fff;" target="_blank">查看操作指引</a>
      </Button>
    </div>
    <dt-grid ref="table" :page='page' :onFetch='onFetch' />
  </div>
</template>
<script>
  import reportMgr from '@/biz/report/report'
  import toolApi from '@/biz/base/tool'
  import columnOpt from './opt/resportStatisticsColumn.js'
  export default {
    data() {
      return {
        page: {
          total: 0,
        },
      }
    },
    methods: {
      // 去详情
      goDetails(val) {
        if (val.sendCustomerCount > 0) {
          this.$router.push({
            path: '/marketingCenter/propertyReport/propertyReport/reportList',
            query: {
              ByvalUserId: val.userId,
              ByvalStatus: '3',
            },
          })
        } else {
          this.$Message.warning('暂无数据')
        }
      },
      onFetch(data) {
        this.paramsAll = {
          ...data,
          buildingId: this.$dt.buildInfo().housesId,
        }
        return reportMgr
          .reportStatisticsList(this.paramsAll).then(res => {
            this.page.total = res.total
            return res.list
          }).catch(err => {
            this.total = 0
          })

      },

      backListReportExport() {
        let params = {
          buildingId: this.$dt.buildInfo().housesId,
        }
        toolApi.downloadCenter('/dt-marketing/v1/report/backUserReportExport', params)
      },
    },
    computed: {},
    created() {},
    mounted() {
      this.$refs.table.init(this, new columnOpt(this))
      this.$refs.table.fetch()
    },
  }
</script>
<style lang="scss" scoped>
  .allCustomersManagement {
    padding-top: 10px;
  }

  .export {
    margin: 10px 0 10px 30px;
    display: flex;
    flex-direction: row;
    justify-content: space-between;
  }
</style>